package com.kreedx.duitang.scrapy;

import com.geccocrawler.gecco.pipeline.Pipeline;
import com.geccocrawler.gecco.scheduler.StartSchedulerContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Service("imgPipeline")
@Slf4j
public class ImgPipeline implements Pipeline<ImgWrapper> {
    @Override
    public void process(ImgWrapper imgWrapper) {
        log.info(imgWrapper.toString());
        ImgWrapper.Detail detail = imgWrapper.getDetail();
        if (detail != null) {
            Integer next = detail.getNext();
            if (next != null) {
                StartSchedulerContext.into(imgWrapper.getRequest().subRequest("https://www.duitang.com/blog/?id=" + next));
            }
        }
    }
}
